package com.example.onlinemarket.bean;

import java.io.Serializable;

public class Page implements Serializable {
    private Integer currentPage;//当前页号
    private Integer pageSize = 5;//单页大小
    private Integer totalPages;//总页数
    private Integer totalRecords;//总记录数

    public Page() {
        currentPage = 1;
        pageSize = 5;
    }

    public Page(Integer currentPage, Integer pageSize, Integer totalRecords) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalPages = totalRecords%pageSize==0?totalRecords/pageSize:totalRecords/pageSize+1;
        this.totalRecords = totalRecords;
    }

    public Page(Integer pageSize, Integer totalRecords) {
        this.currentPage = 1;
        this.pageSize = pageSize;
        this.totalPages = totalRecords%pageSize==0?totalRecords/pageSize:totalRecords/pageSize+1;
        this.totalRecords = totalRecords;
    }

    @Override
    public String toString() {
        return "Page{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalPages=" + totalPages +
                ", totalRecords=" + totalRecords +
                '}';
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(Integer totalRecords) {
        this.totalRecords = totalRecords;
    }
}
